﻿
using System;
using Common.Object;
using System.Data;

namespace CoreApi.Meta
{
    public class ReturnValue
    {
        public bool Passed { get; set; }
        public object Data { get; set; }

        public ReturnValue()
            :this(true,null)
        {
        }

        public ReturnValue(bool passed,object obj)
        {
            this.Passed = passed;
            this.Data = obj;
        }

        public ReturnValue(object data)
            :this(true,data)
        {
        }

        public ReturnValue(Exception ex)
            :this(false,ex)
        {
        }

        public override string ToString()
        {
            return string.Format("Passed:{0},Data:{1}", this.Passed ? "True" : "False", (this.Data is DataTable)?string.Format("Rows:{0}",(this.Data as DataTable).Rows.Count):this.Data.ToJson());
        }

    }
}
